﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SelectCatalogueDropDownList.ascx.cs" Inherits="LEARNREN.COM.WebSite.UserDefinedControls.SelectCatalogueDropDownList" %>
<%@ Register Src="CatalogueTree.ascx" TagName="CatalogueTree" TagPrefix="uc1" %>
<script type="text/javascript">
    var <%="$"+this.ID+"Tree" %>;
    $(<%="init"+this.ID%>);

    function <%="init"+this.ID%>(){   
        <%="$"+this.ID+"Tree" %>=$('#<%=this.ID+"Tree" %>');  
        $('#<%=this.ID+"OpenTree"%>').unbind();
        $('#<%=this.ID+"OpenTree"%>').click(
            function () {
                <%="$"+this.ID+"Tree" %>.toggle();
                return false;
            }).button();
        <%="$"+this.ID+"Tree" %>.hide();
        <%=this.ID+"FitTree" %>();
    }

    function <%=ValidationMethodName %>(source,args) { 
        if(args.Value=="--请选择--")
        {
            args.IsValid=false;
        }
        else
        {
            args.IsValid=true;
        }
    }
    function <%=this.ID+"FitTree" %>(){
       var $treePannel= $('#<%=this.ID+"Tree" %>');
       var $txt=$('#<%=txtSelectedCatalogueTitle.ClientID %>');
       var left=$txt.offset().left;
       var width=Math.floor($txt.width());
       var marginTop="-"+$txt.css("margin-bottom");
       var paddingLeft=$txt.css("padding-left");
       var paddingRight=$txt.css("padding-right");
       $treePannel.css("z-index",1000)
                  .css("position","absolute")
                  .css("left",left)
                  .css("min-width",width)
                  .css("background","#fff")
                  .css("border","1px solid #ccc")
                  .css("margin-top",marginTop)
                  .css("padding","5px")
                  .css("padding-left",paddingLeft)
                  .css("padding-right",paddingRight);
       $treePannel.addClass("ui-corner-all").addClass("ui-widget-content");
    }
</script>
<asp:TextBox ID="txtSelectedCatalogueTitle" runat="server" Enabled="false" Text="--请选择--"></asp:TextBox>
<asp:HiddenField ID="txtSelectedCatalogueId" runat="server" Value="0" />
<asp:HiddenField ID="txtSelectedCataloguePath" runat="server" Value="" />
<span id="<%=this.ID+"OpenTree" %>" style="text-align: center; font-size: 12px; vertical-align: middle; margin-top: -3px;">选择</span>
<asp:CustomValidator ID="CatalogueCustomValidator" runat="server" ErrorMessage="必须选择栏目" ControlToValidate="txtSelectedCatalogueTitle" Display="Dynamic" ForeColor="Red" ToolTip="必须选择栏目" ValidateEmptyText="True">*</asp:CustomValidator>
<div id="<%=this.ID+"Tree" %>">
    <uc1:CatalogueTree ID="CatalogueTree1" runat="server" OnSelectedNodeChanged="CatalogueTree1_SelectedNodeChanged" />
</div>
